package cn.unknownerror.ueteam.gui.frames;

import cn.unknownerror.ueteam.data.ConfigurationManager;
import cn.unknownerror.ueteam.team.ITeam;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class PlayerManageButton extends CommandButton{

    private OfflinePlayer executed;

    public PlayerManageButton(ConfigurationManager config,String name){
        super(config,name);
    }

    public void setExecuted(OfflinePlayer executed) {
        this.executed = executed;
    }

    @Override
    public ItemStack onCreate(ITeam team) {
        String str = "GUI.Customize."+name+".";
        ItemStack item = new ItemStack(Material.getMaterial(str + "material"));
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(config.getString(str + "display_name"));
        meta.setLore(config.getStringList(str +"lore"));
        item.setItemMeta(meta);
        return item;
    }

    @Override
    public void onClick(Player player) {
        Bukkit.dispatchCommand(player,config.getString("GUI.Customize."+name+".func").replaceAll("%player%",executed.getName()));
    }

}
